package com.cwd.controller;

import java.util.List;
import java.util.Date;

import com.cwd.entity.FcFlowProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.cwd.service.IFcFlowProductService;

/**
 * <p>
 * 自主产品表  前端控制器
 * </p>
 * @author cwd
 * @since 2017-04-06
 */
@Controller
@RequestMapping("/fcFlowProduct")
public class FcFlowProductController {
    
    @Autowired private IFcFlowProductService fcFlowProductService;
    
    @GetMapping("/list")
    @ResponseBody
    public List<FcFlowProduct> list() {
        return fcFlowProductService.selectList(null);
    }


    /*@PostMapping("/dataGrid")
    @ResponseBody
    public PageInfo dataGrid(FcFlowProduct fcFlowProduct, Integer page, Integer rows, String sort,String order) {
        EntityWrapper<FcFlowProduct> ew = new EntityWrapper<FcFlowProduct>();
        ew.setEntity(fcFlowProduct);
        Page<FcFlowProduct> pages = getPage(page, rows, sort, order);
        pages = fcFlowProductService.selectPage(pages,ew);
        return pageToPageInfo(pages);
    }
    
    *//**
     * 添加页面
     * @return
     *//*
    @GetMapping("/addPage")
    public String addPage() {
        return "admin/fcFlowProduct/fcFlowProductAdd";
    }

    *//**
     * 添加
     * @param 
     * @return
     *//*
    @PostMapping("/add")
    @ResponseBody
    public Object add(FcFlowProduct fcFlowProduct) {
        fcFlowProduct.setCreateTime(new Date());
        fcFlowProduct.setUpdateTime(new Date());
        fcFlowProduct.setDeleteFlag(0);
        boolean b = fcFlowProductService.insert(fcFlowProduct);
        if (b) {
            return renderSuccess("添加成功！");
        } else {
            return renderError("添加失败！");
        }
    }

    *//**
     * 删除
     * @param id
     * @return
     *//*
    @PostMapping("/delete")
    @ResponseBody
    public Object delete(Long id) {
        FcFlowProduct fcFlowProduct = new FcFlowProduct();
        fcFlowProduct.setId(id);
        fcFlowProduct.setUpdateTime(new Date());
        fcFlowProduct.setDeleteFlag(1);
        boolean b = fcFlowProductService.updateById(fcFlowProduct);
        if (b) {
            return renderSuccess("删除成功！");
        } else {
            return renderError("删除失败！");
        }
    }

    *//**
     * 编辑
     * @param model
     * @param id
     * @return
     *//*
    @GetMapping("/editPage")
    public String editPage(Model model, Long id) {
        FcFlowProduct fcFlowProduct = fcFlowProductService.selectById(id);
        model.addAttribute("fcFlowProduct", fcFlowProduct);
        return "admin/fcFlowProduct/fcFlowProductEdit";
    }

    *//**
     * 编辑
     * @param 
     * @return
     *//*
    @RequestMapping("/edit")
    @ResponseBody
    public Object edit(FcFlowProduct fcFlowProduct) {
        fcFlowProduct.setUpdateTime(new Date());
        boolean b = fcFlowProductService.updateById(fcFlowProduct);
        if (b) {
            return renderSuccess("编辑成功！");
        } else {
            return renderError("编辑失败！");
        }
    }*/
    
}
